package snail.misc;


import org.springframework.web.servlet.mvc.multiaction.InternalPathMethodNameResolver;

/**
 *  Fixar så man kommer till index-actionen om man inte skriver nån action i url:en
 * @author viktor
 */
public class CustomUrlMethodNameResolver extends InternalPathMethodNameResolver {

    @Override
    protected String getHandlerMethodNameForUrlPath(String urlPath) {
        String s = super.getHandlerMethodNameForUrlPath(urlPath);
        if (s == null || s.equals("")) {
            s = "index";
        }
        return s;
    }

    @Override
    protected String extractHandlerMethodNameFromUrlPath(String uri) {
        String s = super.extractHandlerMethodNameFromUrlPath(uri);
        if (s == null || s.equals("")) {
            s = "index";
        }
        return s;
    }

    @Override
    protected String postProcessHandlerMethodName(String methodName) {
        String s = super.postProcessHandlerMethodName(methodName);
        if (s == null || s.equals("")) {
            s = "index";
        }
        return s;
    }
}
